<template>
  <div class="ma-content-block">
    <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm">
      <!-- 搜索区 tableSearch -->
      <template #tableSearch>
        <a-col :sm="8" :xs="24">
          <a-form-item label="直播间名称" field="name">
            <a-input v-model="searchForm.name" placeholder="请输入直播间名称" allow-clear />
          </a-form-item>
        </a-col>
        <a-col :sm="8" :xs="24">
          <a-form-item label="直播间ID" field="room_id">
            <a-input v-model="searchForm.room_id" placeholder="请输入直播间ID" allow-clear />
          </a-form-item>
        </a-col>
      </template>
      <template #start_time="{ record }">
        {{ tool.timestampToTime(record.start_time) }}
      </template>
      <template #end_look_time="{ record }">
        {{ tool.timestampToTime(record.end_look_time) }}
      </template>
      <!-- Table 自定义渲染 -->
    </sa-table>

    <!-- 编辑表单 -->
    <!-- <edit-form ref="editRef" @success="refresh" /> -->

  </div>
</template>

<script setup>
import { onMounted, ref, reactive } from 'vue'
import { Message } from '@arco-design/web-vue'
import api from '@/api/live/live'
import tool from '@/utils/tool'


// 引用定义
const crudRef = ref()

// 搜索表单
const searchForm = ref({
  name: '',
  room_id: '',
})

// SaTable 基础配置
const options = reactive({
  api: api.volumeList,
  rowSelection: { showCheckedAll: true },
  add: {
    show: false,
  },
  delete: {
    show: false,
  },
})

// SaTable 列配置
const columns = reactive([
  { title: '直播间ID', dataIndex: 'room_id', width: 180 },
  { title: '直播间名称', dataIndex: 'name', width: 180 },
  { title: '消耗量(G)', dataIndex: 'webinar_flow', width: 180 },
  { title: '直播间人数', dataIndex: 'people', width: 180 },
  { title: '总时长', dataIndex: 'total_time', width: 180 },
  { title: '开播时间', dataIndex: 'start_time', width: 180 },
  { title: '直播结束时间', dataIndex: 'end_look_time', width: 180 },
  { title: '操作', dataIndex: '__operation', width: 0 },
])

// 页面数据初始化
const initPage = async () => {}

// SaTable 数据请求
const refresh = async () => {
  crudRef.value?.refresh()
}

// 页面加载完成执行
onMounted(async () => {
  initPage()
  refresh()
})
</script>
